package com.comsumer.RabbitMQ;
import com.comsumer.config.MQConfig;
import com.comsumer.config.Result;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
@RabbitListener(queues = MQConfig.QUEUE_NAME)
public class ComsumerMQ {
    @Autowired
    private RestTemplate restTemplate;
    private static final String REST_URL_PREFIX="http://producer/good";
    @RabbitHandler
    public void getReleaseOrderMessage(String message)  {
        System.out.println("MQ运行");
        restTemplate.getForObject(REST_URL_PREFIX+"/addNums", Result.class);
    }
}
